# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
@follow=(uid,obj)->
  $.ajax '/follow',
    type:'POST'
    data:{follow:{followed_id:uid}}
    dataType:'json'
    success:(data,textStatus,jqXHR)->
      if data.stat==1
        $(obj).attr('onclick','unfollow('+uid+',this)').html '取消关注'
        $('.followercount').html parseInt($('.followercount').html())+1

@unfollow=(uid,obj)->
  $.ajax '/unfollow',
    type:'POST'
    data:{follow:{followed_id:uid}}
    dataType:'json'
    success:(data,textStatus,jqXHR)->
      if data.stat==1
        $(obj).attr('onclick','follow('+uid+',this)').html '加关注'
        $('.followercount').html parseInt($('.followercount').html())-1